package com.xyz.controller;

import com.xyz.aop.ObjectParam;
import com.xyz.dto.CountDto;
import com.xyz.service.HomeAllService;
import com.xyz.util.dto.DataResult;
import com.xyz.util.dto.LoginInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("homeAll")
public class HomeAllController {

    private static final Logger logger = LoggerFactory.getLogger(HomeAllController.class);

    @Autowired
    private HomeAllService homeAllService;

    @PostMapping("selectHead")
    public DataResult selectHead(LoginInfo loginInfo, @ObjectParam CountDto countDto) {
        try {
            return homeAllService.selectHead(loginInfo, countDto);
        } catch (Exception e) {
            logger.error("selectHead", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("selectRepair")
    public DataResult selectRepair(LoginInfo loginInfo, @ObjectParam CountDto countDto) {
        try {
            return homeAllService.selectRepair(loginInfo, countDto);
        } catch (Exception e) {
            logger.error("selectFault", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("selectEmRepair")
    public DataResult selectEmRepair(LoginInfo loginInfo, @ObjectParam CountDto countDto) {
        try {
            return homeAllService.selectEmRepair(loginInfo, countDto);
        } catch (Exception e) {
            logger.error("selectEmRepair", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("selectPatrol")
    public DataResult selectPatrol(LoginInfo loginInfo, @ObjectParam CountDto countDto) {
        try {
            return homeAllService.selectPatrol(loginInfo, countDto);
        } catch (Exception e) {
            logger.error("selectPatrol", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("selectHour")
    public DataResult selectHour(LoginInfo loginInfo, @ObjectParam CountDto countDto) {
        try {
            return homeAllService.selectHour(loginInfo, countDto);
        } catch (Exception e) {
            logger.error("selectHour", e);
            return DataResult.build9500();
        }
    }

}
